package com.zcxy360.sandtable.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtil {
	
	public static void main(String[] args) {
	}
	
	public static boolean isNumeric(String str) {
		for (int i = 0; i < str.length(); i++) {
			if (!Character.isDigit(str.charAt(i))) {
				return false;
			}
		}
		return true;
	}
	
	public static boolean isNotEmpty(String str){
		return str != null && !"".equals(str.trim());
	}
	public static boolean isEmpty(String str){
		return str == null || "".equals(str.trim());
	}

	public static String wrapper(String key) {
		return isEmpty(key)?null:"%"+key+"%";
	}
	
	public static int count(String str) {
		int count = 0;
		Pattern pattern = Pattern.compile("[\\u4E00-\\u9FA5]");
		Matcher matcher = pattern.matcher(str);
		while(matcher.find()) {
			count++;
		}
		return count;
	}
	
	public static String generateDefaultPassword(String phone) {
		return phone.substring(3);
	}
}
